package org.gd.rest.jersey.client;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;

import javax.ws.rs.core.MediaType;

/**
 * @author Gorhover
 * @version 1.0-SNAPSHOT
 * @since 2013-10-17 19:16
 */
public class DeleteAcquiringClient {

    private static final String PROTOCOL = "http";
    private static final String HOST = "localhost";//"10.42.14.143";
    private static final Integer PORT = 8000;
    private static final String APP = "Acquiring";
    private static final String PATH = String.format("%s://%s:%d/%s",
            PROTOCOL, HOST, PORT, APP);

    public static void main(String[] args) {
        long t = System.currentTimeMillis();
        Client client = Client.create();
        WebResource webResource = client
                .resource(getUrl());
        ClientResponse response = webResource
//                .queryParam()
//                .entity(content, MediaType.APPLICATION_XML)
                .accept(MediaType.APPLICATION_XML)
                .delete(ClientResponse.class);
        if (response.getStatus() != 200) {
            System.err.println("Failed : HTTP error code : " + response.getStatus());
        }
        String output = response.getEntity(String.class);
        System.out.printf("Output from Server .... %s (t: %s ms)\n",
                output,
                System.currentTimeMillis() - t);
    }

    private static String getUrl() {
        return PATH + "/admin/p48/retailer/775447";
    }
}
